package cn.cloudplug.instar_ec.main.login;

import android.os.Bundle;
import android.support.v7.widget.AppCompatEditText;
import android.view.View;

import butterknife.BindView;
import butterknife.OnClick;
import cn.cloudplug.instar_ec.R;
import cn.cloudplug.instar_ec.R2;
import cn.cloudplug.instar_ec.main.base.StatusBarDelegate;
import cn.cloudplug.instar_ec.main.fingerprint.CreateFingerprintDelegate;
import cn.cloudplug.instar_ec.main.index.IndexDelegate;
import cn.cloudplug.zdx_core.model.FingerprintModel;

/**
 * Created by pc on 2018/1/22.
 */

public class LoginDelegate extends StatusBarDelegate {

    @BindView(R2.id.et_name_login)
    AppCompatEditText edt_name;

    @BindView(R2.id.et_pwd_login)
    AppCompatEditText edt_pwd;

    @OnClick(R2.id.btn_login)
    void clickLogin(){
        String name = edt_name.getText().toString();
        String pwd = edt_pwd.getText().toString();

        //test
        if(!FingerprintModel.getInstance().haveFingerprint()){
            getSupportDelegate().startWithPop(new IndexDelegate());
            getSupportDelegate().start(new CreateFingerprintDelegate());
        }else{
            getSupportDelegate().startWithPop(new IndexDelegate());
        }

    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
    }

    private boolean checkForm(String name,String pwd) {
        boolean isPass=true;

        if (name==null||"".equals(name)){
            isPass=false;
        }

        if (pwd == null||"".equals(pwd)||pwd.length()<6){
            isPass=false;

        }

        return isPass;
    }

    @Override
    protected Object setLayout() {
        return R.layout.delegate_login;
    }

    @Override
    protected void onBindView(Bundle savedInstanceState, View view) {

    }
}
